//
//  SHDetails2ViewController.m
//  News
//
//  Created by dlios on 15-5-15.
//  Copyright (c) 2015年 PEAK. All rights reserved.
//

#import "SHDetails2ViewController.h"
#import "SDuanzi2TableViewCell.h"
#import "SDuanziTableViewCell.h"

@interface SHDetails2ViewController ()<UIWebViewDelegate>

@property(nonatomic, retain)NSMutableArray *ArrOne;
@property(nonatomic, retain)NSMutableArray *ArrTwo;
@property(nonatomic, retain)NSDictionary *dic;
@property(nonatomic, retain)UIWebView *web;
@property(nonatomic, retain) UIActivityIndicatorView *activityIndicator;
@property(nonatomic ,retain)UIImageView *imageView;
@end

@implementation SHDetails2ViewController

- (void)dealloc
{
    
    [_activityIndicator release];
    [_imageView release];
    [_dic release];
    [_web release];
    [_strOne release];
    
    [super dealloc];
}

- (void)viewWillAppear:(BOOL)animated
{
    self.tabBarController.tabBar.hidden = YES;
}
- (void)viewWillDisappear:(BOOL)animated
{
    self.tabBarController.tabBar.hidden = NO;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
 
     self.automaticallyAdjustsScrollViewInsets = YES;
    self.navigationController.navigationBar.translucent = NO;
    
           //请求出现小菊花
        self.imageView  = [[UIImageView alloc] initWithFrame:self.view.bounds];
        _imageView.image = [UIImage imageNamed:@"5EA2D64D-15BE-43D8-AB18-E15BCE039C8F"];
        _imageView.alpha =0.6;
        [self.view addSubview:_imageView];
            _activityIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 32.0f, 32.0f)];
        [_activityIndicator setCenter:_imageView.center];
        _activityIndicator.backgroundColor= [UIColor grayColor];
        [_activityIndicator setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleWhite];
        [_imageView addSubview:_activityIndicator];
            [_activityIndicator startAnimating];

    [self details];
}


-(void)details
{
   
    NSString *str = [NSString stringWithFormat:@"http://c.m.163.com/nc/article/%@/full.html",_strOne];

    [SNetWorkHandle  getDataWithURL:str completion:^(id result) {
        
        NSDictionary *xiangqingDic = [result objectForKey:_strOne];
        self.xiangqing = [[SHppyObject alloc] initWithDic:xiangqingDic];
        
           self.dic = [NSMutableDictionary dictionary];
          _dic = result;

        [self create];
     }];
    
}

-(void)create
{
    self.web
    =[[UIWebView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - _web.frame.size.height)];
    [_web loadHTMLString:_xiangqing.body baseURL:nil];
    [self.view addSubview:_web];
    _web.scrollView.bounces = NO;
    _web.delegate = self;
    [_web release];
    
}
// 文本高度
+ (CGFloat)heightWithText:(NSString *)text
{
    NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:14]};
    CGSize size = CGSizeMake(375, 1000);
    CGRect rect = [text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    return rect.size.height;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
